package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.service.QuestionService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @auther wangchenghao
 * @date 2020/10/2
 **/
@Controller
@ResponseBody
@RequestMapping("question")
public class QuestionController {
    @Autowired
    QuestionService questionService;

    @ApiOperation("查询所有题目")
    @RequestMapping(value = "/getList", method = {RequestMethod.GET})
    public BaseModel getList() throws Exception {
        BaseModel model = new BaseModel();
        questionService.queryAllList(model);
        return model;
    }

    @ApiOperation("查询单个题目")
    @RequestMapping(value = "/getById", method = {RequestMethod.GET})
    public BaseModel getById(@ApiParam("题目id") @RequestParam(value = "question_id", required = true) Integer question_id) throws Exception {
        BaseModel model = new BaseModel();
        questionService.selectById(question_id, model);
        return model;
    }
}
